import { http } from '../../utils/request'

// 获取文章新闻推荐
export const getArticles = (channel_id) => {
  // 异步 action 需要返回函数
  return async (dispatch) => {
    const res = await http.get('/v1_0/articles', {
      params: {
        channel_id: channel_id,
        timestamp: Date.now(),
      },
    })
    // console.log(res.data.results)
    dispatch({ type: 'news/setList', payload: res.data.results })
  }
}
